package mypi;

import java.math.BigDecimal;

public class MainTest {

	private static final int SCALE = 5000; 
	private static final int WORK_SIZE = 5000;

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		
		long time = System.currentTimeMillis();
		BigDecimal result = new BigDecimal("0");
		result = result.setScale(SCALE);
		int numIterations = SCALE / WORK_SIZE;
		for (int i = 0; i < numIterations; i++) {
			System.out.println("1: create tasks");
			PiTask piCalc = new PiTask(i, i * WORK_SIZE, (i + 1) * WORK_SIZE,
					SCALE);// (i+1)*WORK_SIZE+10);
			piCalc.run();
			result = result.add(((MyResult) (piCalc.getResult())).getValue());
		}
		System.out.println(result);
		//long end = System.currentTimeMillis();
		System.out.println("Time: " + (System.currentTimeMillis() - time));

//
//		long time = System.currentTimeMillis();
//
//		BigDecimal result = new BigDecimal("0");
//		result = result.setScale(SCALE);
//		int numIterations = SCALE / WORK_SIZE;
//		for(int i = 0;i < numIterations; i++){
//			PiTask piCalc = new PiTask(i,i*WORK_SIZE, (i+1)*WORK_SIZE,SCALE);//(i+1)*WORK_SIZE+10);
//			
//			piCalc.run();
//			System.out.println(piCalc.getResult());
//
//			result = result.add(((MyResult)(piCalc.getResult())).getValue());
//			System.out.println(result);
//			System.out.println(System.currentTimeMillis()-time);
//			time = System.currentTimeMillis();
//		}
//
//		System.out.println(result);

	}


}
